Enable preview deployments and PR comments in docs-preview-local#3297
Enable preview deployments and PR comments in docs-preview-local#3297itsalexcm wants to merge 2 commits into
Conversation
Enable GitHub deployments (were gated off), grant deployments:write, and post a bot comment with the handbook preview base URL plus links to changed Markdown pages when the local docs build succeeds. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis workflow update activates the docs-preview GitHub Deployment and adds automatic PR commenting. The 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/docs-preview-local.yml (1)
195-198:⚠️ Potential issue | 🟠 Major | ⚡ Quick winGate PR comments on actual preview publish success.
Lines 385-387 only require
needs.build.result == 'success'. The build job can still be “success” when docs build/upload were skipped, so this job may post dead preview links.Proposed fix
build: outputs: deployment_result: ${{ steps.deployment.outputs.result }} path_prefix: ${{ steps.generate-path-prefix.outputs.result }} + preview_published: ${{ steps.s3-upload.outcome == 'success' }} comment: if: > github.event_name == 'pull_request' && needs.check.outputs.any_modified == 'true' && needs.build.outputs.path_prefix != '' - && needs.build.result == 'success' + && needs.build.outputs.preview_published == 'true'Also applies to: 382-387
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/docs-preview-local.yml around lines 195 - 198, The job's gating condition currently checks only needs.build.result == 'success', which can be true even when docs publish was skipped; update the job 'if' condition to also require the deployment output to indicate a real preview was published by adding a check for needs.build.outputs.deployment_result == 'success' (i.e. require both needs.build.result == 'success' && needs.build.outputs.deployment_result == 'success'), and apply the same change where the condition appears (referencing needs.build.result and needs.build.outputs.deployment_result and the outputs deployment_result/path_prefix from steps.deployment and steps.generate-path-prefix).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/docs-preview-local.yml:
- Around line 434-442: Replace the single-page listComments call with a full
pagination call and tighten the bot identity check: use
github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
to retrieve all comment pages into comments, then find existing by matching
c.user.login === 'github-actions[bot]' && c.body.startsWith(title) (instead of
c.user.type) so you won't miss existing comments on busy PRs or accidentally
match other bots.
---
Outside diff comments:
In @.github/workflows/docs-preview-local.yml:
- Around line 195-198: The job's gating condition currently checks only
needs.build.result == 'success', which can be true even when docs publish was
skipped; update the job 'if' condition to also require the deployment output to
indicate a real preview was published by adding a check for
needs.build.outputs.deployment_result == 'success' (i.e. require both
needs.build.result == 'success' && needs.build.outputs.deployment_result ==
'success'), and apply the same change where the condition appears (referencing
needs.build.result and needs.build.outputs.deployment_result and the outputs
deployment_result/path_prefix from steps.deployment and
steps.generate-path-prefix).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: a6bbf2fa-f30b-43f3-a5f6-eb1155dd1543
📒 Files selected for processing (1)
.github/workflows/docs-preview-local.yml
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| }) | ||
| const existing = comments.find( | ||
| (c) => | ||
| c.user.type === 'Bot' && c.body.startsWith(title) | ||
| ) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat .github/workflows/docs-preview-local.yml | wc -lRepository: elastic/docs-builder
Length of output: 68
🏁 Script executed:
sed -n '420,460p' .github/workflows/docs-preview-local.ymlRepository: elastic/docs-builder
Length of output: 1297
🏁 Script executed:
# Search for context around the comment upsert logic
sed -n '400,480p' .github/workflows/docs-preview-local.ymlRepository: elastic/docs-builder
Length of output: 2169
🌐 Web query:
GitHub Actions @actions/github paginate listComments API documentation
💡 Result:
@actions/github “paginate” for listComments: use Octokit pagination (Link-header driven) on the REST endpoint that lists issue comments (issues/{issue_number}/comments). The REST endpoint supports pagination via the page and per_page query parameters (max 100) and also supports since filtering; GitHub paginates results using the response Link header when there are more results. [1][2][3] In GitHub Actions, the @actions/github package provides a hydrated Octokit client (github.getOctokit / octokit.rest.*). [4] Use octokit.paginate with the list-comments endpoint so it automatically fetches all pages until the last page, returning a single array of items. [2][3] Example (actions/github-script / Node JS): const comments = await github.paginate(github.rest.issues.listComments, { owner: context.repo.owner, repo: context.repo.repo, issue_number: 123, per_page: 100, }); This pattern is also used in the official actions/github-script discussion as the fix when listComments exceeds the single-page default of 30. [5] Key REST details for listComments / issue comments: - Endpoint: GET /repos/{owner}/{repo}/issues/{issue_number}/comments [1] - Pagination query parameters: page (default 1), per_page (default 30, max 100) [1] Octokit pagination mechanics: - GitHub Docs’ pagination guide states that Octokit’s paginate fetches next pages until the last page and returns all items as a single array. [3]
Citations:
- 1: https://docs.github.com/v3/issues/comments
- 2: https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api
- 3: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2026-03-10
- 4: https://github.com/actions/toolkit/tree/main/packages/github
- 5: How to retrieve all PR/issue comments? actions/github-script#474
🌐 Web query:
@actions/github github.paginate method documentation
💡 Result:
In GitHub Actions, @actions/github exposes an authenticated Octokit client and supports pagination via octokit.paginate (and related iterator helpers) when using the underlying Octokit REST pagination plugin. What documentation exists for github.paginate / octokit.paginate 1) Official GitHub REST API pagination docs (Octokit integration) GitHub documents that for paginated REST API results you can use octokit.paginate, which fetches the next page until the last page and returns all items as a single array; it also supports a map function and octokit.paginate.iterator to iterate page-by-page. [1][2] 2) Authoritative Octokit plugin documentation: @octokit/plugin-paginate-rest The plugin-paginate-rest package documentation states that it adds octokit.paginate which accepts the same parameters as octokit.request; it wraps octokit.request and continues requesting while there is a rel="next" link in the response Link header. It also notes only “List...” endpoints are supported for pagination and that non-list endpoints behave like octokit.request. [3] What the method does (high-confidence behavior) - octokit.paginate wraps octokit.request and keeps requesting the “next” URL as long as the response Link header contains rel="next". [3] - It returns all fetched items as a single array (even when the underlying raw REST result was an object, octokit.paginate returns an array of items). [1][2] - You can supply a map function to process each page’s results and optionally end early by calling done. [1] - Alternatively, octokit.paginate.iterator lets you iterate one page/response at a time, more memory-efficient than collecting everything. [1] How this maps to @actions/github - @actions/github is a hydrated Octokit client returned by getOctokit(token). [4][5] - As part of the standard usage, the client retains pagination APIs (github.paginate) consistent with Octokit.js (used in github-script examples). For example, actions/github-script shows calling await github.paginate(opts) to get all pages of a REST list endpoint. [6] Practical example pattern (from official docs) - For REST: use octokit.paginate with the REST “list” endpoint route/params, and optionally map. GitHub’s docs explicitly recommend octokit.paginate for fetching paginated results via Octokit.js. [1] If you meant pagination for GraphQL - There is a separate plugin for GraphQL pagination: octokit.graphql.paginate, which paginates by scanning for pageInfo and using endCursor when hasNextPage is true. [7] Most relevant references to read - GitHub Docs: “Using pagination in the REST API” (Octokit.paginate + iterator + map function). [1][2] - Octokit plugin: @octokit/plugin-paginate-rest.js (how octokit.paginate is implemented via Link header rel="next"). [3] - @actions/github package overview (shows it returns an authenticated Octokit client and is how Actions code gets an Octokit instance). [4][5]
Citations:
- 1: https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api
- 2: https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2026-03-10
- 3: https://github.com/octokit/plugin-paginate-rest.js/
- 4: https://www.npmjs.com/package/@actions/github
- 5: https://github.com/actions/toolkit/tree/main/packages/github
- 6: https://github.com/actions/github-script/
- 7: https://github.com/octokit/plugin-paginate-graphql.js/
Fetch all comment pages to avoid duplicates and strict bot identity match.
This only fetches the first page (~30 comments) and matches any bot. On busy PRs, it misses the existing comment, creating duplicates. Use github.paginate() to fetch all pages and match specifically against github-actions[bot] to avoid accidentally updating other bots' comments.
Proposed fix
- const { data: comments } = await github.rest.issues.listComments({
- owner,
- repo,
- issue_number,
- })
+ const comments = await github.paginate(
+ github.rest.issues.listComments,
+ { owner, repo, issue_number, per_page: 100 }
+ )
const existing = comments.find(
(c) =>
- c.user.type === 'Bot' && c.body.startsWith(title)
+ c.user?.login === 'github-actions[bot]' &&
+ c.body?.startsWith(title)
)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/docs-preview-local.yml around lines 434 - 442, Replace the
single-page listComments call with a full pagination call and tighten the bot
identity check: use github.paginate(github.rest.issues.listComments, { owner,
repo, issue_number }) to retrieve all comment pages into comments, then find
existing by matching c.user.login === 'github-actions[bot]' &&
c.body.startsWith(title) (instead of c.user.type) so you won't miss existing
comments on busy PRs or accidentally match other bots.
Wire OTEL_EXPORTER_OTLP_ENDPOINT via WebApplicationFactory settings so mapOtlpEndpoints runs consistently under parallel CI. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/3297/ |
Enable GitHub deployments (were gated off), grant deployments:write, and post a bot comment with the handbook preview base URL plus links to changed Markdown pages when the local docs build succeeds.